package org.davidtrevien.com.imput.omi.panels.top.menu;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JToggleButton;

import org.davidtrevien.com.imput.omi.callback.NavigationCallback;
import org.davidtrevien.utils.controler.Controller;

public class MenuCtrl
	extends Controller<MenuView> {

	protected NavigationCallback callback;
	
	public MenuCtrl(final NavigationCallback callback) {
		this.callback = callback;
		
		initComponent();
		initListener();
	}

	private void initComponent() {
		this.view = new MenuView();
	}
	
	private void initListener() {
		ActionListener action = new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				JToggleButton button = (JToggleButton) e.getSource();
				MenuCtrl.this.callback.notifyNavigationToggleChanged(button);
			}
		};
		
		this.view.planningToggle.addActionListener(action);
		this.view.holidayToggle.addActionListener(action);
		this.view.imputationToggle.addActionListener(action);
		this.view.osToggle.addActionListener(action);
		this.view.paramToggle.addActionListener(action);
	}
}
